import os, sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from sqlist import SqList

def delete_duplicates(sq):
    """Delete duplicates from sorted sequential list
    Time: O(n), Space: O(1)"""
    if sq.size <= 1:
        return
    
    k = 0  # index for unique elements
    for i in range(1, sq.size):
        if sq.data[i] != sq.data[k]:
            k += 1
            sq.data[k] = sq.data[i]
    sq.size = k + 1

if __name__ == "__main__":
    sq = SqList()
    sq.CreateList([1, 2, 2, 3, 3, 3, 4, 5, 5])
    delete_duplicates(sq)
    print(sq.display())  # Expected: [1, 2, 3, 4, 5]